<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <title>后台主页模块 - XzcBlogTemplate后台管理</title>
    <link href="static/layui/css/layui.css" rel="stylesheet">
    <link href="static/admin/css/common.css" rel="stylesheet" type="text/css">
    <link href="static/admin/css/blogadd.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="layui-container main">
    <div class="layui-row layui-col-space20">
        <div class="layui-col-md12">
            <p>
		        	<span class="layui-breadcrumb" style="visibility: visible;">
			          	<a href="bloglist.html">博客管理系统</a><span lay-separator="">/</span>
			          	<a href="bloglist.html">后台首页</a><span lay-separator="">/</span>
			          	<a><cite>博文添加</cite></a>
		        	</span>
            </p>
        </div>
        <div class="layui-col-md12">
            <form action="" class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input max_width500" lay-verify="required" name="title" placeholder="请输入标题"
                               required type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">分类</label>
                    <div class="layui-input-block">
                        <select lay-verify="required" name="type">
                            <option class="max_width500" value=""></option>
                            <option class="max_width500" value="JAVA基础">JAVA基础</option>
                            <option class="max_width500" value="数据库">数据库</option>
                            <option class="max_width500" value="JSP">JSP</option>
                            <option class="max_width500" value="框架">框架</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">置顶</label>
                    <div class="layui-input-block">
                        <input lay-skin="switch" name="switch" type="checkbox">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" id="editor" name="desc" placeholder="请输入内容"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-filter="formDemo" lay-submit>立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script src="static/js/jquery-1.12.4.min.js"></script>
<script src="static/layui/layui.all.js"></script>
<script>
    $(document).ready(function () {
        $("[class='layui-btn']").click(function () {
            var title = $("[name='title']").val();
            var detail = $("[id='editor']").prop('value'); // 使用 val() 方法获取 textarea 的值
            var type = $("[name='type']").val();
            var uid = sessionStorage.getItem("uid");
            var status = $("[name='switch']").prop('checked') ? 1 : 0;
            $.get("Blog/insert", {
                "title": title,
                "detail": detail,
                "type": type,
                "uid": uid,
                "status": status
            }, function (rs) {
            });
        });
    });
</script>
</html>